<template>
  <div class="info" v-loading="loading">
    <div class="card_con search_data mb15">
      <el-row>
        <el-col :span="8" class="pr40">
          <div class="fz13 mb10">状态：</div>
          <el-select v-model="moneyStatusId" placeholder="请选择">
            <el-option
              v-for="item in moneyStatusArr"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="4">
          <div class="fz13 mb10">&nbsp;</div>
          <el-button type="primary" @click="handleSearch">查询</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="card_con">
      <el-table
        border
        :data="tableData"
        :header-cell-style="{
          'text-align': 'center',
        }"
        :cell-style="{ 'text-align': 'center' }"
        style="width: 100%"
        highlight-current-row
      >
        <el-table-column prop="token" label="代币名称" min-width="20%">
        </el-table-column>
        <el-table-column prop="class" label="记账分类" min-width="15%">
        </el-table-column>
        <el-table-column prop="first" label="原始金额" min-width="10%">
        </el-table-column>
        <el-table-column prop="last" label="最后金额" min-width="10%">
        </el-table-column>
        <el-table-column
          prop="ramount"
          label="实际金额(已入账)"
          min-width="20%"
        >
        </el-table-column>
        <el-table-column prop="status" label="状态" min-width="10%">
          <template slot-scope="scoped">
            <div v-if="scoped.row.status === 0" class="red">待入帐</div>
            <div v-if="scoped.row.status === 1" class="green">已入账</div>
            <div v-if="scoped.row.status === 2">已驳回</div>
          </template>
        </el-table-column>
        <el-table-column prop="time" label="写入时间" min-width="20%">
        </el-table-column>
        <el-table-column prop="release" label="释放时间" min-width="20%">
        </el-table-column>

        <el-table-column label="操作" min-width="20%">
          <template slot-scope="scope">
            <div class="caozuo">
              <div
                class="handleExamine hand_cs"
                @click="handleDetail(scope.row)"
              >
                更多
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <Pagination :page="page" @onCurrentChange="handleCurrentChange" />
      </div>
      <el-dialog
        class="detailDialog"
        title="详情"
        :visible.sync="detailDialog"
        width="700px"
      >
        <DetailDialog v-if="detailDialog" :rowData="rowData"></DetailDialog>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination.vue";
import DetailDialog from "./transaction_flow_detail_dialog.vue";
import { transaction_flow } from "@/api/merchant";
export default {
  components: { Pagination, DetailDialog },
  data() {
    return {
      loading: true,
      page: {
        total: 0,
        pageNum: 1, // 当前页数
        pageSize: 10, // 每页的条数
      },
      tableData: [
        {
          id: "6",
          hf_id: "123243",
          tel: "18582669937",
          location: "成都市武侯区",
          logo: require("@/assets/1.png"),
          leixing: "入驻",
          status: "启用",
          create_time: "2022-5-19",
        },
      ],
      moneyStatusArr: [
        { id: -1, name: "全部" },
        { id: 0, name: "待入帐" },
        { id: 1, name: "已入账" },
        { id: 2, name: "已驳回" },
      ],
      moneyStatusId: -1,
      detailDialog: false,
      rowData: "",
    };
  },
  methods: {
    async transaction_flow() {
      const { data, err } = await transaction_flow({
        page: this.page.pageNum,
        status: this.moneyStatusId,
      });
      if (err === 0) {
        this.loading = false;
        this.tableData = data.data;
        this.page.pageSize = data.per_page;
        this.page.total = data.total;
      }
    },
    //详情
    handleDetail(row) {
      this.rowData = row;
      this.detailDialog = true;
    },
    handleSearch() {
      this.loading = true;
      this.page.pageNum = 1;
      this.transaction_flow();
    },
    // 当前页: ${val}
    handleCurrentChange(val) {
      this.page.pageNum = val;
      this.loading = true;
      this.transaction_flow();
    },
  },
  created() {
    this.transaction_flow();
  },
};
</script>

<style lang="scss" scoped>
@import "@/style/index.scss";
.handleExamine {
  margin-left: 20px;
}
.info {
  .title {
    font-size: 16px;
    margin-bottom: 13px;
  }
}
.pagination {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}
.el-select {
  width: 100%;
}

.tb {
  background-color: #fff;
  padding: 20px;
  box-sizing: border-box;
}
.row {
  display: flex;
  border-radius: 2px;
  .l {
    padding: 8px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
    font-size: 13px;
    i {
      margin-right: 6px;
      font-size: 13px;
    }
    &:hover {
      cursor: pointer;
    }
  }
  .l:nth-child(3) {
    border-right: 0;
  }
}
.caozuo {
  display: flex;
  justify-content: center;
  .handleDelete {
    margin-left: 20px;
  }
}
.detailDialog {
  /deep/.el-dialog {
    height: 72%;
    margin-top: 10vh !important;
    .el-dialog__body {
      height: 80%;
      overflow: auto;
    }
  }
}
.beizhu {
  padding: 0 20px 50px 20px;
  box-sizing: border-box;
  .bz {
    margin-bottom: 10px;
    margin-top: 20px;
  }
  .btn {
    margin-top: 20px;
    .el-button {
      width: 100%;
    }
  }
}
</style>
